package edu.ped.android.nfc;

import greendroid.app.GDActivity;
import greendroid.widget.ActionBarItem;
import greendroid.widget.ActionBarItem.Type;
import android.content.Intent;

public class ActionBarManager {

	private static final int INFO = 0;
	private static final int SETTINGS = 1;

	public static final int INTERACTIVENFC = 0;
	public static final int DRAWPICTURE = 1;
	public static final int GESTURE = 2;
	public static final int GESTURES = 3;
	public static final int INITALIZATION = 4;
	public static final int MANAGE = 5;
	public static final int PAINTS= 6;
	public static final int SHOWPICTURE = 7;
	public static final int SHOWRULES = 8;
	public static final int TIMEDISTANCE = 9;
	public static final int ABOUT = 10;
	public static final int PARAMETERS = 11;
	public static final int LANGUAGE_SELECTION = 12;
	public static final int TICTACTOE = 13;
	public static final int LABYRINTH = 14;

	public static String language = "";
	
	public static void initActionBar(GDActivity activity, int id ){
		String title = null;
		switch(id){
		case INTERACTIVENFC : 
			title = activity.getResources().getString(R.string.app_name);
			break;
		case DRAWPICTURE :
			title = activity.getResources().getString(R.string.draw);
			break;
		case GESTURE :
			title = activity.getResources().getString(R.string.launch);
			break;
		case GESTURES :
			title = activity.getResources().getString(R.string.gesture);
			break;
		case INITALIZATION :
			title = activity.getResources().getString(R.string.init);
			break;
		case MANAGE :
			title = activity.getResources().getString(R.string.manage);
			break;
		case PAINTS :
			title = activity.getResources().getString(R.string.paint);
			break;
		case SHOWPICTURE :
			title = activity.getResources().getString(R.string.show);
			break;
		case SHOWRULES :
			title = activity.getResources().getString(R.string.show);
			break;
		case TIMEDISTANCE:
			title = activity.getResources().getString(R.string.time);
			break;
		case ABOUT:
			title = activity.getResources().getString(R.string.about);
			break;
		case PARAMETERS :
			title = activity.getResources().getString(R.string.parameters);
			break;
		case LANGUAGE_SELECTION:
			title = activity.getResources().getString(R.string.parameters);
		case TICTACTOE :
			title = activity.getResources().getString(R.string.tictactoe);
		case LABYRINTH :
			title = "labyrinth";
		default :
			title = "";
		}
		activity.setTitle(title);
		activity.addActionBarItem(Type.Info,INFO);
		activity.addActionBarItem(Type.Settings,SETTINGS);
	}

	public static boolean handleActionBar(GDActivity activity,ActionBarItem item, int position){
		Intent intent;
		switch (position) {
		case INFO:
			if(!(activity instanceof AboutActivity)){
				intent = new Intent(activity,edu.ped.android.
						nfc.AboutActivity.class);
				activity.startActivity(intent);
			}
			break;

		case SETTINGS:
			if(!(activity instanceof ParametersActivity)){
				intent = new Intent(activity,ParametersActivity.class);
				activity.startActivity(intent);
			}
			break;

		default:
			return activity.onHandleActionBarItemClick(item, position);
		}

		return true;
	}
}
